// =============================================================================
angular.module('junlebao', ['ui.router','junlebao.controllers'])

.run(function($rootScope,$state,$location){
	$rootScope.$on("$stateChangeSuccess",function(){
		if($rootScope.user=null){
			alert("user null");
			console.log("fff");
		}
	});
})
// configuring our routes 
// =============================================================================
.config(function($stateProvider, $urlRouterProvider) {
    
    $stateProvider
        // route to show our basic form (/form)
        .state('tologin', {
            url: '/login',
            templateUrl: 'template/login.html',
        })
        
        .state('home', {
            url: '/home',
            templateUrl: 'template/home.html'
        })
        
        .state('home2', {
            url: '/home2',
            templateUrl: 'template2/home2.html'
        })
        
        .state('make_product', {
            url: '/make_product',
            templateUrl: 'template2/make_product.html'
        })
        
        .state('makeqrc', {
            url: '/makeqrc/:shop_id',
            templateUrl: 'template2/makeqrc.html'
        })
        
        .state('information', {
            url: '/information',
            templateUrl: 'template/information.html'
        })
        
        .state('information2', {
            url: '/information2',
            templateUrl: 'template2/information2.html'
        })
        
        .state('groupbuy', {
            url: '/groupbuy',
            templateUrl: 'template/groupbuy.html'
        })
        .state('product_save', {
            url: '/product/save',
            templateUrl: 'template/product_save.html'
        })
        .state('register', {
            url: '/register',
            templateUrl: 'template/resistphone.html'
        })
        
        .state('findpassword', {
            url: '/findpassword',
            templateUrl: 'template/findpassword.html'
        })
        
        .state('product_list', {
            url: '/product/list',
            templateUrl: 'template/product_list.html'
        })
        .state('haveproduct', {
            url: '/haveproduct',
            templateUrl: 'template2/haveproduct.html'
        })
        .state('searchshop', {
            url: '/searchshop',
            templateUrl: 'template/searchshop.html'
        })
        
        .state('searchshop2', {
            url: '/searchshop2',
            templateUrl: 'template2/searchshop2.html'
        })
        
        .state('outbound', {
            url: '/outbound',
            templateUrl: 'template/outbound.html'
        })
        .state('outdetails', {
            url: '/outdetails',
            templateUrl: 'template/outdetails.html'
        })
        .state('makeorder', {
            url: '/makeorder/:data',
            templateUrl: 'template/makeorder.html'
        })
        .state('partners', {
            url: '/partners',
            templateUrl: 'template/partners.html'
        })
        
        .state('partners2', {
            url: '/partners2',
            templateUrl: 'template2/partners2.html'
        })
        
        .state('ordernum', {
            url: '/ordernum',
            templateUrl: 'template/ordernum.html'
        })
        .state('shopmap', {
            url: '/shopmap',
            templateUrl: 'template/shopmap.html'
        })
        .state('safety', {
            url: '/safety',
            templateUrl: 'template/safety.html'
        })
        .state('safety2', {
            url: '/safety2',
            templateUrl: 'template2/safety2.html'
        })
        .state('password', {
            url: '/password',
            templateUrl: 'template/password.html'
        })
        .state('password2', {
            url: '/password2',
            templateUrl: 'template2/password2.html'
        })
         .state('isloading', {
            url: '/isloading/:toUrl',
            controller:'isloading'
        })
    // catch all route
    // send users to the form page 
    $urlRouterProvider.otherwise('/login');
})

//map_url="http://uri.amap.com/navigation?from=116.478346,39.997361,startpoint&to=116.3246,39.966577,endpoint&via=116.402796,39.936915,midwaypoint&mode=car&policy=1&src=mypage&coordinate=gaode&callnative=0";
//      url22="http://m.amap.com/navi/?start=116.403124,39.940693&dest=116.481488,39.990464&destName=阜通西&naviBy=car&key=78652d823906badf373dd319727d8701";
//map_url="http://uri.amap.com/navigation?from=116.478346,39.997361,startpoint&to=116.3246,39.966577,endpoint&via=116.402796,39.936915,midwaypoint&mode=car&policy=1&src=mypage&coordinate=gaode&callnative=0";
//      url22="http://m.amap.com/navi/?start=116.403124,39.940693&dest=116.481488,39.990464&destName=阜通西&naviBy=car&key=78652d823906badf373dd319727d8701";